<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <!--{include file='comm/comm_cal.tpl'}-->
    <title>会员发送消息列表</title>
</head>
<body>

<div class="container">

    <div class="comm_crub">
            <span class="now_crub">会员发送消息列表【<!--{$message_title}-->】</span>
            <button type="button" class="btn btn-primary" style="float: right;margin:4px 15px 0px 0px;" onclick="history.go(-1)">返回上一级</button>
        </div>

    <div class="comm_content">
            <div class="search-box">
                <div style="position:relative">
                    <form id="search_form" class="form-inline" onsubmit="return false;">
                        <table>
                            <tbody>
                            <tr>
                                <td>
                                    <span>会员名：<input type="text" id="custID" class="form-control input-sm w300"  name="custID" value="" /></span>
                                    <span>
                                        是否已读：
                                            <select class="form-control input-sm w150" id="is_read" name="is_read">
                                                <option value="" selected>请选择</option>
                                                <option value="0">否</option>
                                                <option value="1">是</option>
                                            </select>
                                    </span>
                                    <span>
                                        是否已回复：
                                            <select class="form-control input-sm w150" id="is_reply" name="is_reply">
                                                <option value="" selected>请选择</option>
                                                <option value="0">否</option>
                                                <option value="1">是</option>
                                            </select>
                                    </span>
                                    <span>
                                        回复日期：
                                        <input class="form-control" style="width:170px;" id="startDate" name="startDate" value="" readonly="readonly" type="text" />
                                        ～
                                        <input class="form-control" style="width:170px;" id="endDate" name="endDate" value="" readonly="readonly" type="text" />

                                    </span>
                                    <input type="button" value="查询" class="btn btn-primary" onclick="message.search();" />
                                    <input type="button" value="重置" class="btn btn-warning" onclick="message.reset();" />
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </form>
                </div>
            </div>

            <table id="flex" style="display:none"></table>

        </div>

</div>



<script type="text/javascript">

$("#flex").flexigrid({
    url:"/invokingAjax-backend/customer/message.ajax?operFlg=3&message_id="+<!--{$message_id}-->,
    dataType: "json",
    colModel : [
        {display: "会员名",align: "left", width : 200},
        {display: "发送时间",align: "center", width : 130},
        {display: "是否已读",align: "center", width : 70},
        {display: "是否已回复",align: "center", width : 70},
        {display: "回复日期",align: "center", width : 130},
        {display: "回复内容", width : 600}
    ],

    buttons : [
        {name: "删除", bclass: "delete", onpress : "message.del.check"},
        {separator: true},
        {name: "全选", bclass: "checkAll", onpress : "E.checkAllList"},
        {separator: true},
        {name: "取消全选", bclass: "cancelCheckAll", onpress : "E.cancelCheckAllList"}
    ],
    sortname: "message_id",
    sortorder: "desc",
    usepager: true,
    rp: 10,
    useRp: true,
    showTableToggleBtn: true,
    autoload: true,
    onSubmit: function() {
        var dt = $("#search_form").serializeArray();
        $("#flex1").flexOptions({params: dt});
        return true;
    }
});

$('#startDate').datetimepicker({timeFormat:'HH:mm:ss',showHour: true,showMinute: true,showSecond: true,});
$('#endDate').datetimepicker({timeFormat:'HH:mm:ss',showHour: true,showMinute: true,showSecond: true,hour: 23,minute: 59,second:59,});

var message = {

    //搜索会员
    search: function() {
        var dt = $('#search_form').serializeArray();
        $("#flex").flexOptions({params: dt}).flexReload();
    },
    //重置
    reset: function() {
        $('#custID').val('');
        $('#is_read').val('');
        $('#is_reply').val('');
        $('#startDate').val('');
        $('#endDate').val('');

        this.search();
    },

    del: {

        p_array: '',

        check: function() {

            var p_obj = $('#flex').find('tr.trSelected');
            if (p_obj.length == 0) {
                E.alert('请选择要删除的会员发送消息');
            } else {

                var temp_array = new Array();
                var error_flg = 0;

                $.each(p_obj, function(k, v) {
                    var id = $(v).attr('id').replace('row', '');

                    temp_array.push($(v).attr('id').replace('row', ''));
                });

                    this.p_array = temp_array;
                    E.confirm('您确认要删除选中的会员发送消息吗？', 'message.del.execute');

            }

        },

        execute: function() {
            E.loadding.open('正在删除，请稍候...');
            E.ajax_post({
                url: '/invokingAjax-backend/customer/message.ajax?operFlg=101&act=del',
                data: {
                    p_array: this.p_array
                },
                call: 'message.del.result'
            });
        },

        result: function( o ) {

            E.loadding.close();
            if (o.code == 200) {
                E.alert('删除成功', 2, 'message.load');
            } else {
                E.alert(o.message);
            }

        }

    },



    load: function() {
        $("#flex").flexReload();
    }


};

</script>

</body>
</html>